package vista;

import com.nilo.plaf.nimrod.NimRODLookAndFeel;
import com.nilo.plaf.nimrod.NimRODProgressBarUI;
import com.nilo.plaf.nimrod.NimRODTheme;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.ProgressBarUI;

/**
 * CEntradita
 * Clase Entradita es la primera ventana
 * de bienvenida hacia el usuario
 *
 * @author Cristina Carrillo
 * @version 1.00, 2/04/2011
 *
 */
public class CEntradita extends javax.swing.JFrame implements Runnable {

    /**
     * este metodo Run nos muestra el codigo para un hilo o thread que se va carganado
     * poco a poco antes de ingresar al programa

     * @param no tiene parametro

     *
     * @return el metodo es de tipo void en el cual no tiene retorno
     */
    public void run() {
        try {
            initComponents();
            setIconImage(new ImageIcon(getClass().getResource("/vista/Imagenes/linux.png")).getImage());
            setVisible(true);
            for (int i = 0; i <= 100; i += 5) {
                if (i == 5) {
                    lblTextito.setText("Cargando Modulos...");
                } else if (i == 50) {
                    lblTextito.setText("Cargando Librerias...");
                } else if (i == 90) {
                    lblTextito.setText("Iniciando el programa...");
                }
                jpbEntrada.setBackground(Color.BLACK);
                jpbEntrada.setForeground(jpbEntrada.getForeground());
                jpbEntrada.setUI((ProgressBarUI) NimRODProgressBarUI.createUI(null));
                jpbEntrada.setValue(i);
                Thread.sleep(200);
            }
        } catch (InterruptedException ex) {
            Logger.getLogger(CEntradita.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception e) {
        }

        try {
            BufferedReader br = new BufferedReader(new FileReader(System.getProperty("user.dir") + "/Sersw.fc"));
            this.dispose();
            new CPrincipal().setVisible(true);
        } catch (FileNotFoundException ex) {
            this.dispose();
            new CPrincipal().setVisible(true);
//                new VentanaPrincipal(5).setVisible(true);
//                JOptionPane.showMessageDialog(new VentanaPrincipal(5), "Para poder acceder a los menus deshabilitados debe crear un usuario");
        } catch (IOException e) {
            System.out.println(e);
        }
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jpbEntrada = new javax.swing.JProgressBar();
        lblTextito = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("HEALING SYSTEM");
        setUndecorated(true);

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1 = new CPanel("inicio.jpg");

        jpbEntrada.setForeground(new java.awt.Color(204, 0, 204));
        jpbEntrada.setName("jpbEntrada"); // NOI18N

        lblTextito.setForeground(new java.awt.Color(102, 0, 102));
        lblTextito.setName("lblTextito"); // NOI18N

        jLabel1.setFont(new java.awt.Font("Broadway", 1, 18));
        jLabel1.setForeground(new java.awt.Color(0, 0, 102));
        jLabel1.setText("Integrates:");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel2.setForeground(new java.awt.Color(153, 0, 153));
        jLabel2.setText("HEALING SYSTEM");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setForeground(new java.awt.Color(153, 0, 153));
        jLabel3.setText("® Copyright (C) 2010-20");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vista/Imagenes/125.png"))); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setFont(new java.awt.Font("Broadway", 1, 14)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(0, 0, 102));
        jLabel5.setText("SISTEMA EXPERTO PARA EL RECONOCIMIENTO DE PLANTAS MEDICINALES");
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setFont(new java.awt.Font("Comic Sans MS", 1, 14));
        jLabel6.setForeground(new java.awt.Color(255, 0, 0));
        jLabel6.setText("@ Cristina Carrillo");
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel10.setFont(new java.awt.Font("Broadway", 1, 18));
        jLabel10.setForeground(new java.awt.Color(0, 0, 102));
        jLabel10.setText("Docente:");
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel11.setFont(new java.awt.Font("Comic Sans MS", 1, 14));
        jLabel11.setForeground(new java.awt.Color(255, 0, 0));
        jLabel11.setText("@ Ing. Edison Coronel");
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel12.setFont(new java.awt.Font("Broadway", 1, 18));
        jLabel12.setText("SISTEMAS EXPERTOS");
        jLabel12.setName("jLabel12"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(252, 252, 252)
                        .addComponent(lblTextito, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(138, 138, 138)
                                .addComponent(jLabel6))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(79, 79, 79)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel10)
                                    .addComponent(jLabel1)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(139, 139, 139)
                                .addComponent(jLabel11))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(187, 187, 187)
                                .addComponent(jLabel12)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(191, 191, 191)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(47, 47, 47)
                        .addComponent(jpbEntrada, javax.swing.GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE)))
                .addContainerGap(16, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 630, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jpbEntrada, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addGap(43, 43, 43)
                .addComponent(lblTextito, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-630)/2, (screenSize.height-326)/2, 630, 326);
    }// </editor-fold>//GEN-END:initComponents

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                CEntradita e = new CEntradita();
                Thread t = new Thread(e);
                t.start();
                NimRODTheme nt = new NimRODTheme();
                //Pone en rojo los colores
                nt.setPrimary1(new Color(184, 00, 00));
                nt.setPrimary2(new Color(194, 00, 00));
                nt.setPrimary3(new Color(204, 00, 00));
                nt.setSecondary1(new Color(220, 220, 220));
                nt.setSecondary2(new Color(230, 230, 230));
                nt.setSecondary3(new Color(240, 240, 240));

                //Pone en azul los colores
//                nt.setPrimary1(new Color(00, 133, 235));
//                nt.setPrimary2(new Color(00, 143, 245));
//                nt.setPrimary3(new Color(00, 153, 255));
//                nt.setSecondary1(new Color(220, 220, 220));
//                nt.setSecondary2(new Color(230, 230, 230));
//                nt.setSecondary3(new Color(240, 240, 240));
                nt.setWhite(new Color(250, 250, 250));
                nt.setBlack(new Color(0, 0, 0));
                nt.setOpacity(0);
                nt.setMenuOpacity(0);
                nt.setFrameOpacity(0);
                NimRODLookAndFeel nlf = new NimRODLookAndFeel();
                nlf.setCurrentTheme(nt);

                try {
                    UIManager.setLookAndFeel(nlf);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(CEntradita.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JProgressBar jpbEntrada;
    private javax.swing.JLabel lblTextito;
    // End of variables declaration//GEN-END:variables
}
